home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-13 | 3.1 KB | 109 lines | [TEXT/CWIE] |
- //=====================================================================================
- // File: FinderPopAPI.c
- //
- // Contains: FinderPop Application Programming Interface (Implementation)
- //
- // Written by: turly o’connor, cork, ireland turly@geocities.com
- //
- // Copyright: 1997, 1998 by Turlough O'Connor, all rights reserved.
- //
- // Change History (most recent first):
- // <02> 23-Sep-98 tur Add FinderPoplets!
- // <01> 01-Sep-98 tur Make Beta Version publicly available.
- //
- //=====================================================================================
-
- #include <Gestalt.h>
- #include <Errors.h>
- #include "FinderPopAPI.h"
-
-
- //=====================================================================================
- // OpenFinderPopConnection
- //
- // Opens a FinderPop "connection" (in reality a ProcPtr to the internal FinderPop
- // routine which handles the connection.) This routine is 68K, so on a PowerMac,
- // we allocate a RoutineDescriptor which is returned as the "cookie", so make sure
- // you dispose of it by calling CloseFinderPopConnection() - q.v.
- //
- //=====================================================================================
-
- TFinderPopCookie OpenFinderPopConnection(void)
- {
- long fp;
-
- if (Gestalt(kFinderPopAPIGestaltSignature, &fp) != noErr)
- fp = 0;
- else
- if (fp != 0)
- fp = *((long *)fp); // sorry guys -- the other fields are private :-)
-
- #if GENERATINGPOWERPC
- if (fp != 0) // create a RoutineDescriptor for the 68K code pointed to by FP
- { // Ahem -- in the system heap, please...!
- THz oldZone = GetZone();
- SetZone(SystemZone());
- UniversalProcPtr apiProc = NewRoutineDescriptor((ProcPtr)fp, uppFinderPopAPIProcInfo, kM68kISA);
- SetZone(oldZone);
- fp = (long)apiProc;
- }
- #endif /* GENERATINGPOWERPC */
-
- return (TFinderPopCookie)fp;
- }
-
-
- /**/
-
-
- //=====================================================================================
- // CloseFinderPopConnection
- //
- // For PowerMacs, dispose of the cookie routine descriptor. Always return zero.
- //
- //=====================================================================================
-
- TFinderPopCookie CloseFinderPopConnection(TFinderPopCookie fpCookie)
- {
- #if GENERATINGPOWERPC
- if (fpCookie != 0)
- DisposeRoutineDescriptor((UniversalProcPtr)fpCookie);
- #endif
-
- return 0;
- }
-
-
- /**/
-
-
- //=====================================================================================
- // FinderPopAPIProc
- //
- // Use the cookie which points at the internal FinderPop routine to handle the
- // 3rd-party API. Basically, pass the buck to FinderPop's FinderPopPrefsProc()
- // routine.
- //
- //=====================================================================================
-
- SInt32 FinderPopAPIProc(TFinderPopCookie fpCookie, UInt32 selector, SInt32 param)
- {
- SInt32 result;
-
- if (fpCookie != 0)
- {
- #if GENERATINGPOWERPC
- result = CallUniversalProc((UniversalProcPtr)fpCookie, uppFinderPopAPIProcInfo, selector, param);
- #else
- typedef pascal SInt32 (*TInternalFinderPopAPIProc)(UInt32 selector, SInt32 param);
- result = ((TInternalFinderPopAPIProc)fpCookie)(selector, param);
- #endif
- }
- else
- result = paramErr;
-
- return result;
- }
-
- /* EOF FinderPopAPI.c */
-